﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Stone_Jumper
{
    class Gravity
    {
        private  double _fallCount = 0;
        private  double _bounceCount = 0;
        public void MakeGravity(Jumper jumper)
        {
           
               
                if (jumper.JumperState == JumperStateEnum.HasToFallDown)
                {
                  
                    if (this._fallCount <= 0.0)
                    {
                        this.PlayerGoDown(jumper, 0.05);
                    }
                    else if (this._fallCount <= 0.4)
                    {
                        this.PlayerGoDown(jumper, 0.08);
                    }
                    else if (this._fallCount <= 0.8)
                    {
                        this.PlayerGoDown(jumper, 0.15);
                    }
                    else if (this._fallCount <= 1.3)
                    {
                        this.PlayerGoDown(jumper, 0.3);
                    }
                    else if (this._fallCount <= 2.0)
                    {
                        this.PlayerGoDown(jumper, 0.5);
                    }
                    else if (this._fallCount <= 3.0)
                    {
                        this.PlayerGoDown(jumper, 0.8);
                    }
                    else if (this._fallCount < 1000.0)
                    {
                        this.PlayerGoDown(jumper, 1.6);
                    }
                    this._fallCount += 0.1;
                }


                else
                {
                   
                    if (this._bounceCount <= 10f)
                    {
                        this.PlayerGoUp(jumper,1.3);
                    }
                    else if (this._bounceCount <= 15f)
                    {
                        this.PlayerGoUp(jumper,0.7);
                    }
                    else if (this._bounceCount <= 20f)
                    {
                        this.PlayerGoUp(jumper, 0.3);
                    }
                    else if (this._bounceCount <= 24f)
                    {
                        this.PlayerGoUp(jumper, 0.1);
                    }
                    else if (this._bounceCount <= 27f)
                    {
                        this.PlayerGoUp(jumper, 0.05);
                    }
                    else if (this._bounceCount > 27f)
                    {
                        this._bounceCount = 0;
                        this._fallCount = 0.0;
                        jumper.JumperState = JumperStateEnum.HasToFallDown;
                    }
                    this._bounceCount += 0.1;
                }
            
        }
        private void PlayerGoDown(Jumper jumper,double i)
        {
            jumper.position.Y += (float)i;
           
        }

        private void PlayerGoUp(Jumper jumper,double i)
        {
            jumper.position.Y -= (float)i;
           
        }
    }

}
